package org.uva.streambuilder;

import java.applet.Applet;
import java.awt.Color;
import java.awt.Graphics;
import java.util.Observable;


public class ThresholdStreamModule extends StreamModule {

	double threshold = 20;
	
	public ThresholdStreamModule(Applet app, int x, int y) {
		super(app, x, y);
		this.defaultColor = new Color(26, 241, 133);
		this.selectColor = new Color(200, 20, 0, 200);
		this.name = "Theshold";
		
		this.bx = 100;
		this.by = 80;
		
	}
	
	
	public void draw( Graphics g )
	{
		super.draw(g);
		String s = "lbound = " + Double.toString(threshold);
		g.drawString(s , x + textLeftMargin, y + 3*textTopMargin );
	}
	
	public void update(Observable o, Object arg){
		if (arg instanceof Double)
		{
			double val = (Double) arg;
			if (val > threshold)
				setValue (val);
			else
				setValue (0f);
			
		}
		
	};

}
